<?php
if(empty($buid))
msg($config['weburl']."/login.php?forward=".urlencode("$config[weburl]/?m=product&s=shop_order"));
else {

		if ($_POST['act'] != 'reserve') {
			if($config['temp'] != 'wap') {

				$pid = $_POST['pid'];
				$sql = "select * from " .PRO. " where id = '$pid' ";
				$db->query($sql);
				$product_info = $db->fetchRow();
				$tpl->assign('product_info',$product_info);

			} else {

				$id = $_GET['id'] * 1;
				$sql = "select p.* from " .SETMEAL. " s left join ".PRO." p on p.id = s.pid  where s.id = '$id' ";
				$db->query($sql);
				$product_info = $db->fetchRow();
				$tpl->assign('product_info',$product_info);



			}


		} else {
			$param = $_POST;
			foreach($_POST as $key => $val){
				if(!is_array($val)){
					$param[$key] = htmlspecialchars(stripslashes($val));
				} else {
					$param[$key] = $val;
				}
			}
			if(empty($param['user_name']) || empty($param['user_mobile']) || empty($param['price'])){
				msg($config['weburl'],"内容要填写完整");
				return false;
			}
			$time = time();
			$sql = "insert into ".RESERVE." (`uid`,`product_id`, `product_name`, `user_name`, `user_mobile`, `num`, `price`, `mark`,`add_time`) values
					('$buid','{$param['product_id']}', '{$param['product_name']}', '{$param['user_name']}', '{$param['user_mobile']}', '{$param['num']}',
					'{$param['price']}', '{$param['mark']}', '$time')";
			if($db->query($sql)){
				msg($config['weburl'],"提交成功");
			}




		}

}
//=================================================
$tpl->assign("config",$config);
include_once("footer.php");
$out=tplfetch("shop_reserve.htm",'',true);

?>